## Script (Python) "statusmodify"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind state=state
##bind subpath=traverse_subpath
##parameters=last_referer=None
##title=Status Modify
from Products.CMFCore.utils import getToolByName

REQUEST = context.REQUEST
wtool = getToolByName(context, 'portal_workflow')
portal_url = getToolByName (context, 'portal_url')
if context.isShelf():
    came_from = 'bookshelf/myshelf'
else:
    came_from = 'my'
isApp = (context.portal_type == "App")
if isApp :
    parent = context.aq_inner.aq_parent
    review_state = wtool.getInfoFor(parent, "review_state", "")
    if review_state in ('private','paid','rejected'):
        redirect_to = '%s/status_modify?came_from=%s/%s' % (parent.absolute_url(),portal_url(),came_from)
    else:
        redirect_to = '%s/status_modify?came_from=%s/%s' % (context.absolute_url(),portal_url(),came_from)
else:
    redirect_to = '%s/status_modify?came_from=%s/%s' % (context.absolute_url(),portal_url(),came_from)
    
kwargs = {
'next_action':'redirect_to:string:%s' % redirect_to,
}
return state.set(**kwargs)